<!doctype html>
<html lang="zh-Hans" dir="ltr" class="docs-wrapper docs-doc-page docs-version-current plugin-docs plugin-id-default docs-doc-id-changelog/x/2020-10-26-knife4j-2.0.6-issue">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="generator" content="Docusaurus v2.0.1">
<link rel="search" type="application/opensearchdescription+xml" title="Knife4j" href="/opensearch.xml">

<!-- Google Tag Manager -->
    <script>!function(e,t,a,n,g){e[n]=e[n]||[],e[n].push({"gtm.start":(new Date).getTime(),event:"gtm.js"});var m=t.getElementsByTagName(a)[0],r=t.createElement(a);r.async=!0,r.src="https://www.googletagmanager.com/gtm.js?id=GTM-TKBX678",m.parentNode.insertBefore(r,m)}(window,document,"script","dataLayer")</script>
    <!-- End Google Tag Manager -->
<script src="/js/custom.js"></script>
<script src="/js/baidu.js"></script>
<script src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1589206801610969" async crossorigin="anonymous"></script><title data-rh="true">[v2.0.6-2020/10/26 Knife4j 2.0.6发布,支持OpenAPI3及Auth2认证] | Knife4j</title><meta data-rh="true" name="twitter:card" content="summary_large_image"><meta data-rh="true" property="og:url" content="https://doc.xiaominfo.com/docs/changelog/x/2020-10-26-knife4j-2.0.6-issue"><meta data-rh="true" name="docusaurus_locale" content="zh-Hans"><meta data-rh="true" name="docsearch:language" content="zh-Hans"><meta data-rh="true" name="docusaurus_version" content="current"><meta data-rh="true" name="docusaurus_tag" content="docs-default-current"><meta data-rh="true" name="docsearch:version" content="current"><meta data-rh="true" name="docsearch:docusaurus_tag" content="docs-default-current"><meta data-rh="true" property="og:title" content="[v2.0.6-2020/10/26 Knife4j 2.0.6发布,支持OpenAPI3及Auth2认证] | Knife4j"><meta data-rh="true" name="description" content="Knife4j前身是swagger-bootstrap-ui,是一个为Swagger接口文档赋能的工具"><meta data-rh="true" property="og:description" content="Knife4j前身是swagger-bootstrap-ui,是一个为Swagger接口文档赋能的工具"><link data-rh="true" rel="icon" href="/img/favicon.ico"><link data-rh="true" rel="canonical" href="https://doc.xiaominfo.com/docs/changelog/x/2020-10-26-knife4j-2.0.6-issue"><link data-rh="true" rel="alternate" href="https://doc.xiaominfo.com/docs/changelog/x/2020-10-26-knife4j-2.0.6-issue" hreflang="zh-Hans"><link data-rh="true" rel="alternate" href="https://doc.xiaominfo.com/docs/changelog/x/2020-10-26-knife4j-2.0.6-issue" hreflang="x-default"><link data-rh="true" rel="preconnect" href="https://3CRIMRK623-dsn.algolia.net" crossorigin="anonymous"><link rel="stylesheet" href="/assets/css/styles.66359a73.css">
<link rel="preload" href="/assets/js/runtime~main.e0db172c.js" as="script">
<link rel="preload" href="/assets/js/main.c059fb6e.js" as="script">
</head>
<body class="navigation-with-keyboard">
<script>!function(){function e(e){document.documentElement.setAttribute("data-theme",e)}var t=function(){var e=null;try{e=localStorage.getItem("theme")}catch(e){}return e}();null!==t?e(t):window.matchMedia("(prefers-color-scheme: dark)").matches?e("dark"):window.matchMedia("(prefers-color-scheme: light)").matches?e("light"):e("dark")}()</script><div id="__docusaurus">
<div role="region"><a href="#" class="skipToContent_fXgn">跳到主要内容</a></div><nav class="navbar navbar--fixed-top navbarHideable_m1mJ"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Navigation bar toggle" class="navbar__toggle clean-btn" type="button" tabindex="0"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/"><div class="navbar__logo"><img src="/img/knife4j-light.svg" alt="" class="themedImage_ToTc themedImage--light_HNdA"><img src="/img/knife4j-dark.svg" alt="" class="themedImage_ToTc themedImage--dark_i4oU"></div><b class="navbar__title text--truncate">Knife4j</b></a><a class="navbar__item navbar__link" href="/docs/quick-start">文档</a><a class="navbar__item navbar__link changelog" href="/docs/middleware-sources">中间件</a><a class="navbar__item navbar__link changelog" href="/docs/oas">OAS规范</a><a class="navbar__item navbar__link changelog" href="/docs/action">实战指南</a><a aria-current="page" class="navbar__item navbar__link changelog navbar__link--active" href="/docs/changelog">更新日志</a><a class="navbar__item navbar__link changelog" href="/docs/faq">FAQ</a><div class="navbar__item dropdown dropdown--hoverable"><a href="#" aria-haspopup="true" aria-expanded="false" role="button" class="navbar__link">旧版本</a><ul class="dropdown__menu"><li><a class="dropdown__link" target="_blank" href="/v2/index.html">2.0.9</a></li></ul></div></div><div class="navbar__items navbar__items--right"><div class="toggle_MW0i colorModeToggle_x44X"><button class="clean-btn toggleButton_yw5v toggleButtonDisabled_BJd7" type="button" disabled="" title="切换浅色/暗黑模式（当前为暗黑模式）" aria-label="切换浅色/暗黑模式（当前为暗黑模式）"><span><svg viewBox="0 0 13 12" fill="none" xmlns="http://www.w3.org/2000/svg" width="14" height="14" class="lightToggleIcon_SFTY"><g clip-path="url(#clip0_833_8168)"><path d="M6.59998 8.49999C7.98069 8.49999 9.09998 7.3807 9.09998 5.99999C9.09998 4.61928 7.98069 3.49999 6.59998 3.49999C5.21926 3.49999 4.09998 4.61928 4.09998 5.99999C4.09998 7.3807 5.21926 8.49999 6.59998 8.49999Z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path><path d="M6.59985 0.5V1.5" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path><path d="M6.59985 10.5V11.5" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path><path d="M2.7099 2.11L3.4199 2.82" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path><path d="M9.77991 9.17999L10.4899 9.88999" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path><path d="M1.09998 6H2.09998" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path><path d="M11.0999 6H12.0999" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path><path d="M2.7099 9.88999L3.4199 9.17999" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path><path d="M9.77991 2.82L10.4899 2.11" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"></path></g><defs><clipPath id="clip0_833_8168"><rect width="12" height="12" fill="white" transform="translate(0.599976)"></rect></clipPath></defs></svg><svg viewBox="0 0 13 12" width="14" height="14" class="darkToggleIcon_ekgs"><path d="M10.7001 6.39501C10.6215 7.24611 10.3021 8.05721 9.77927 8.7334C9.25646 9.40959 8.55189 9.92291 7.748 10.2133C6.9441 10.5036 6.07414 10.5591 5.2399 10.3731C4.40565 10.187 3.64164 9.76728 3.03726 9.1629C2.43287 8.55851 2.01312 7.7945 1.8271 6.96026C1.64108 6.12602 1.6965 5.25605 1.98688 4.45216C2.27725 3.64826 2.79056 2.94369 3.46675 2.42088C4.14294 1.89808 4.95404 1.57866 5.80515 1.50001C5.30685 2.17414 5.06707 3.00473 5.12941 3.84071C5.19175 4.6767 5.55208 5.46254 6.14485 6.05531C6.73762 6.64808 7.52346 7.0084 8.35944 7.07074C9.19542 7.13308 10.026 6.8933 10.7001 6.39501Z" stroke="currentColor" fill="transparent" stroke-linecap="round" stroke-linejoin="round"></path></svg></span></button></div><a href="https://github.com/xiaoymin/swagger-bootstrap-ui" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link icon" title="View on GitHub">GitHub<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a><div class="searchBox_ZlJk"><button type="button" class="DocSearch DocSearch-Button" aria-label="搜索"><span class="DocSearch-Button-Container"><svg width="20" height="20" class="DocSearch-Search-Icon" viewBox="0 0 20 20"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg><span class="DocSearch-Button-Placeholder">搜索</span></span><span class="DocSearch-Button-Keys"></span></button></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div class="main-wrapper mainWrapper_z2l0 docsWrapper_BCFX"><button aria-label="回到顶部" class="clean-btn theme-back-to-top-button backToTopButton_sjWU" type="button"></button><div class="docPage__5DB"><aside class="theme-doc-sidebar-container docSidebarContainer_b6E3"><div class="sidebar_njMd sidebarWithHideableNavbar_wUlq"><a tabindex="-1" class="sidebarLogo_isFc" href="/"><img src="/img/knife4j-light.svg" alt="" class="themedImage_ToTc themedImage--light_HNdA"><img src="/img/knife4j-dark.svg" alt="" class="themedImage_ToTc themedImage--dark_i4oU"><b>Knife4j</b></a><nav class="menu thin-scrollbar menu_SIkG"><ul class="theme-doc-sidebar-menu menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menuHtmlItem_M9Kj menu__list-item">
<div class="sidebar_donate">
    <div class="sidebar_sponsor">
        <a target="_blank" href="https://www.apifox.com/apiskills/apifox-auto-generates-api-docs/?utm_source=pay&utm_medium=knife4jg"><img src="/images/sponsor/apifox/Apifox IDEA@3x.png">
        </a>
    </div>
    <div class="sidebar_sponsor_submit">
        <a href="/docs/community/donate">成为赞助商</a>
    </div>
<div>
</div></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist" aria-expanded="false" href="/docs/changelog">4.x版本</a><button aria-label="打开/收起侧边栏菜单「4.x版本」" type="button" class="clean-btn menu__caret"></button></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret menu__link--active" aria-expanded="true" href="/docs/changelog/x/2021-06-28-knife4j-2.0.9-issue">2.x版本</a></div><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/changelog/x/2021-06-28-knife4j-2.0.9-issue">[v2.0.9-2021/06/28 Knife4j 2.0.9发布,解决issue 150+]</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/changelog/x/2020-11-22-knife4j-2.0.8-issue">[v2.0.8-2020/11/22 Knife4j 2.0.8发布,轻量级微服务聚合文档中间件诞生]</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/changelog/x/2020-11-02-knife4j-2.0.7-issue">[v2.0.7-2020/11/02 Knife4j 2.0.7发布,细节处理]</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link menu__link--active" aria-current="page" tabindex="0" href="/docs/changelog/x/2020-10-26-knife4j-2.0.6-issue">[v2.0.6-2020/10/26 Knife4j 2.0.6发布,支持OpenAPI3及Auth2认证]</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/changelog/x/2020-09-14-knife4j-2.0.5-issue">[v2.0.5-2020/09/14 Knife4j 2.0.5发布,性能优化]</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/changelog/x/2020-06-28-knife4j-2.0.4-issue">[v2.0.4-2020/06/28 Knife4j 2.0.4发布,支持自定义 Host]</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/changelog/x/2020-05-24-knife4j-2.0.3-issue">[v2.0.3-2020/05/24 Knife4j 2.0.3发布,支持springdoc和i18n]</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/changelog/x/2020-03-08-knife4j-2.0.2-issue">[v2.0.2-2020/03/08 Knife4j 2.0.2发布,Swagger接口文档赋能工具]</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/changelog/x/2019-12-23-knife4j-2.0.1-issue">[v2.0.1-2019/12/23 Knife4j 2.0.1发布,细节处理！]</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/docs/changelog/x/2019-12-16-knife4j-2.0.0-issue">[v2.0.0-2019/12/16 Knife4j 2.0发布,涅槃重生~！]</a></li></ul></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/docs/changelog/x/2019-08-28-swagger-bootstrap-ui-1.9.6-issue">1.x版本</a></div></li></ul></nav><button type="button" title="收起侧边栏" aria-label="收起侧边栏" class="button button--secondary button--outline collapseSidebarButton_PEFL"><svg width="20" height="20" aria-hidden="true" class="collapseSidebarButtonIcon_kv0_"><g fill="#7a7a7a"><path d="M9.992 10.023c0 .2-.062.399-.172.547l-4.996 7.492a.982.982 0 01-.828.454H1c-.55 0-1-.453-1-1 0-.2.059-.403.168-.551l4.629-6.942L.168 3.078A.939.939 0 010 2.528c0-.548.45-.997 1-.997h2.996c.352 0 .649.18.828.45L9.82 9.472c.11.148.172.347.172.55zm0 0"></path><path d="M19.98 10.023c0 .2-.058.399-.168.547l-4.996 7.492a.987.987 0 01-.828.454h-3c-.547 0-.996-.453-.996-1 0-.2.059-.403.168-.551l4.625-6.942-4.625-6.945a.939.939 0 01-.168-.55 1 1 0 01.996-.997h3c.348 0 .649.18.828.45l4.996 7.492c.11.148.168.347.168.55zm0 0"></path></g></svg></button></div></aside><main class="docMainContainer_gTbr"><div class="container padding-top--md padding-bottom--lg"><div class="row"><div class="col docItemCol_z5aJ"><div class="docItemContainer_c0TR"><article><nav class="theme-doc-breadcrumbs breadcrumbsContainer_Z_bl" aria-label="页面路径"><ul class="breadcrumbs" itemscope="" itemtype="https://schema.org/BreadcrumbList"><li class="breadcrumbs__item"><a aria-label="主页面" class="breadcrumbs__link" href="/"><svg viewBox="0 0 24 24" class="breadcrumbHomeIcon_OVgt"><path d="M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z" fill="currentColor"></path></svg></a></li><li class="breadcrumbs__item"><span class="breadcrumbs__link">2.x版本</span><meta itemprop="position" content="1"></li><li itemscope="" itemprop="itemListElement" itemtype="https://schema.org/ListItem" class="breadcrumbs__item breadcrumbs__item--active"><span class="breadcrumbs__link" itemprop="name">[v2.0.6-2020/10/26 Knife4j 2.0.6发布,支持OpenAPI3及Auth2认证]</span><meta itemprop="position" content="2"></li></ul></nav><div class="tocCollapsible_ETCw theme-doc-toc-mobile tocMobile_ITEo"><button type="button" class="clean-btn tocCollapsibleButton_TO0P">本页总览</button></div><div class="theme-doc-markdown markdown"><h1>[v2.0.6-2020/10/26 Knife4j 2.0.6发布,支持OpenAPI3及Auth2认证]</h1><p><code>Knife4j</code>前身是<code>swagger-bootstrap-ui</code>,是一个为Swagger接口文档赋能的工具</p><p><strong>关键词</strong>：<strong>OpenAPI3</strong>、<strong>Auth2.0</strong>、<strong>AfterScript</strong>、<strong>Springfox3.0</strong>、<strong>增强改善</strong></p><p><strong>文档</strong>：<a href="https://doc.xiaominfo.com/">https://doc.xiaominfo.com</a></p><p><strong>效果(旧版)</strong>：<a href="http://swagger-bootstrap-ui.xiaominfo.com/doc.html" target="_blank" rel="noopener">http://swagger-bootstrap-ui.xiaominfo.com/doc.html</a></p><p><strong>效果(2.X版)</strong>：<a href="http://knife4j.xiaominfo.com/doc.html" target="_blank" rel="noopener">http://knife4j.xiaominfo.com/doc.html</a></p><p><strong>Gitee</strong>：<a href="https://gitee.com/xiaoym/knife4j" target="_blank" rel="noopener">https://gitee.com/xiaoym/knife4j</a></p><p><strong>GitHub</strong>：<a href="https://github.com/xiaoymin/swagger-bootstrap-ui" target="_blank" rel="noopener">https://github.com/xiaoymin/swagger-bootstrap-ui</a></p><p><strong>示例</strong>：<a href="https://gitee.com/xiaoym/swagger-bootstrap-ui-demo" target="_blank" rel="noopener">https://gitee.com/xiaoym/swagger-bootstrap-ui-demo</a></p><h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="特性--优化">特性 &amp; 优化<a class="hash-link" href="#特性--优化" title="标题的直接链接">​</a></h2><p><strong>2.0.6</strong>是继续在上个版本中进行迭代更新,开发者使用OpenAPI2的结构可以直接修改版本号即可进行升级,springfox框架升级到<code>2.10.5</code></p><blockquote><p>springfox 2.10.5 版本变化：</p><p>1、spring-plugin组件升级到2.0.0，移除了guava包</p><p>2、@EnableSwagger2注解升级为@EnableSwagger2WebMvc</p></blockquote><p>Maven引用：</p><div class="language-xml codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-xml codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;</span><span class="token tag" style="color:rgb(255, 121, 198)">dependency</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;</span><span class="token tag" style="color:rgb(255, 121, 198)">groupId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain">com.github.xiaoymin</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;/</span><span class="token tag" style="color:rgb(255, 121, 198)">groupId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;</span><span class="token tag" style="color:rgb(255, 121, 198)">artifactId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain">knife4j-spring-boot-starter</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;/</span><span class="token tag" style="color:rgb(255, 121, 198)">artifactId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token comment" style="color:rgb(98, 114, 164)">&lt;!--OpenAPI2.0的开发者继续使用Knife4j 2.x系列的版本--&gt;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;</span><span class="token tag" style="color:rgb(255, 121, 198)">version</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain">2.0.6</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;/</span><span class="token tag" style="color:rgb(255, 121, 198)">version</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;/</span><span class="token tag" style="color:rgb(255, 121, 198)">dependency</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="复制代码到剪贴板" title="复制" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>1、<strong>OAuth2认证功能的支持:简化模式(implicit)、授权码模式(authorization_code)、密码模式(password)、客户端模式(client_credentials)</strong>,详细规则请<a href="https://doc.xiaominfo.com/knife4j/OAuth2.html">参考文档</a></p><p>2、针对<code>@RequestBody</code>注解标注的请求实体类，在接口请求参数时是否必须(<code>require</code>)的显示异常的问题<a href="https://gitee.com/xiaoym/knife4j/issues/I1VBGB" target="_blank" rel="noopener">Gitee #I1VBGB</a>、<a href="https://gitee.com/xiaoym/knife4j/issues/I1YK2Q" target="_blank" rel="noopener">Gitee #I1YK2Q</a>、<a href="https://gitee.com/xiaoym/knife4j/issues/I1WCMF" target="_blank" rel="noopener">Gitee #I1WCMF</a>、<a href="https://gitee.com/xiaoym/knife4j/issues/I1VDSH" target="_blank" rel="noopener">Gitee #I1VDSH</a>、<a href="https://github.com/xiaoymin/swagger-bootstrap-ui/issues/277" target="_blank" rel="noopener">GitHub #277</a></p><p>3、针对服务端指定<code>consumes</code>的情况优化，如果服务端不指定,Ui会默认根据参数类型进行适配<a href="https://gitee.com/xiaoym/knife4j/issues/I1VE25" target="_blank" rel="noopener">Gitee #I1VE25</a></p><p>4、解决在创建<code>Docket</code>对象时赋予<code>Host</code>属性后,文档界面显示接口地址异常的问题<a href="https://gitee.com/xiaoym/knife4j/issues/I1XYG9" target="_blank" rel="noopener">Gitee #I1XYG9</a></p><p>5、微服务网关聚合文档时,自定义分组名称导致增强失败的问题<a href="https://gitee.com/xiaoym/knife4j/issues/I1Y79W" target="_blank" rel="noopener">Gitee #I1Y79W</a></p><p>6、针对<code>query</code>类型的参数，如果该参数是schema类型,解析该schema为json提作为请求值.<a href="https://gitee.com/xiaoym/knife4j/issues/I1VLHH" target="_blank" rel="noopener">Gitee #I1VLHH</a>,如下图：</p><ul><li>文档展示：</li></ul><p><img loading="lazy" src="/assets/images/query-doc-965fb803ed1062998d6b0357ac78e6be.png" width="923" height="368" class="img_ev3q"></p><ul><li>调试效果：</li></ul><p><img loading="lazy" src="/assets/images/query-debug-7cf5009d0af115e3f56d8ab5b6fc4087.png" width="925" height="349" class="img_ev3q"></p><p>7、调试栏新增<code>AfterScript</code>特性,开发者可根据<code>Knife4j</code>定义的全局变量编写自定义<code>JavaScript</code>脚本,增强接口交互体验<a href="https://gitee.com/xiaoym/knife4j/issues/I1YNU3" target="_blank" rel="noopener">Gitee #I1YNU3</a>、<a href="https://gitee.com/xiaoym/knife4j/issues/I1CAAD" target="_blank" rel="noopener">Gitee #I1CAAD</a>,关于<code>AfterScript</code>特性可参考<a href="https://doc.xiaominfo.com/knife4j/afterScript.html">文档</a></p><p>主要应用场景：</p><ul><li>针对JWT类型的接口,调用登录接口后,每个接口请求时带上Token参数,此时可以通过该脚本动态赋值全局token参数,省去复制粘贴的麻烦.</li></ul><p>假设某一个登录接口响应的JSON内容如下：</p><div class="language-json codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-json codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token punctuation" style="color:rgb(248, 248, 242)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">  </span><span class="token property">&quot;code&quot;</span><span class="token operator">:</span><span class="token plain"> </span><span class="token number">8200</span><span class="token punctuation" style="color:rgb(248, 248, 242)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">  </span><span class="token property">&quot;message&quot;</span><span class="token operator">:</span><span class="token plain"> </span><span class="token null keyword" style="color:rgb(189, 147, 249);font-style:italic">null</span><span class="token punctuation" style="color:rgb(248, 248, 242)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">  </span><span class="token property">&quot;data&quot;</span><span class="token operator">:</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(248, 248, 242)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token property">&quot;token&quot;</span><span class="token operator">:</span><span class="token plain"> </span><span class="token string" style="color:rgb(255, 121, 198)">&quot;1y1tn8tvw93fxixp79dcx0nugixkw4su&quot;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">  </span><span class="token punctuation" style="color:rgb(248, 248, 242)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token punctuation" style="color:rgb(248, 248, 242)">}</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="复制代码到剪贴板" title="复制" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>该接口是登录接口,除该接口外其余接口请求都需要带上<code>token</code>的请求头,因此我们访问登录接口后,设置全局Header参数<code>token</code>,此操作<code>Knife4j</code>接下来会为每一个请求接口带上<code>token</code>参数，代码如下：</p><div class="language-javascript codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-javascript codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token keyword" style="color:rgb(189, 147, 249);font-style:italic">var</span><span class="token plain"> code</span><span class="token operator">=</span><span class="token plain">response</span><span class="token punctuation" style="color:rgb(248, 248, 242)">.</span><span class="token property-access">data</span><span class="token punctuation" style="color:rgb(248, 248, 242)">.</span><span class="token property-access">code</span><span class="token punctuation" style="color:rgb(248, 248, 242)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token keyword control-flow" style="color:rgb(189, 147, 249);font-style:italic">if</span><span class="token punctuation" style="color:rgb(248, 248, 242)">(</span><span class="token plain">code</span><span class="token operator">==</span><span class="token number">8200</span><span class="token punctuation" style="color:rgb(248, 248, 242)">)</span><span class="token punctuation" style="color:rgb(248, 248, 242)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token comment" style="color:rgb(98, 114, 164)">//判断,如果服务端响应code是8200才执行操作</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token comment" style="color:rgb(98, 114, 164)">//获取token</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token keyword" style="color:rgb(189, 147, 249);font-style:italic">var</span><span class="token plain"> token</span><span class="token operator">=</span><span class="token plain">response</span><span class="token punctuation" style="color:rgb(248, 248, 242)">.</span><span class="token property-access">data</span><span class="token punctuation" style="color:rgb(248, 248, 242)">.</span><span class="token property-access">data</span><span class="token punctuation" style="color:rgb(248, 248, 242)">.</span><span class="token property-access">token</span><span class="token punctuation" style="color:rgb(248, 248, 242)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token comment" style="color:rgb(98, 114, 164)">//1、如何参数是Header，则设置全局Header</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    ke</span><span class="token punctuation" style="color:rgb(248, 248, 242)">.</span><span class="token property-access">global</span><span class="token punctuation" style="color:rgb(248, 248, 242)">.</span><span class="token method function property-access" style="color:rgb(80, 250, 123)">setHeader</span><span class="token punctuation" style="color:rgb(248, 248, 242)">(</span><span class="token string" style="color:rgb(255, 121, 198)">&quot;token&quot;</span><span class="token punctuation" style="color:rgb(248, 248, 242)">,</span><span class="token plain">token</span><span class="token punctuation" style="color:rgb(248, 248, 242)">)</span><span class="token punctuation" style="color:rgb(248, 248, 242)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token punctuation" style="color:rgb(248, 248, 242)">}</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="复制代码到剪贴板" title="复制" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>8、通过创建Docket对象时设置<code>globalOperationParameters</code>全局参数时,针对<code>header</code>类型的<code>allowableValues</code>不支持下拉框选择的问题<a href="https://gitee.com/xiaoym/knife4j/issues/I1OC0H" target="_blank" rel="noopener">Gitee #I1OC0H</a></p><p>代码如下：</p><div class="language-java codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-java codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token plain">parameters.add(new ParameterBuilder().name(&quot;header-test&quot;).description(&quot;balabala&quot;)</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                .modelRef(new ModelRef(&quot;string&quot;))</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                .parameterType(&quot;header&quot;)</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                .allowableValues(new AllowableListValues(Arrays.asList(&quot;下拉1&quot;, &quot;下拉2&quot;), &quot;string&quot;))</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                .required(false).order(1).build());</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">new Docket(DocumentationType.SWAGGER_2)</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                .host(&quot;https://www.baidu.com&quot;)</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                .apiInfo(apiInfo())</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                .groupName(&quot;2.X版本&quot;)</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                .globalOperationParameters(parameters)</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="复制代码到剪贴板" title="复制" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>最终效果：</p><p><img loading="lazy" src="/assets/images/header-select-eeefffc3584bda1a7bf17e6565b62f25.png" width="926" height="268" class="img_ev3q"></p><p>9、离线导出功能板块增加导出OpenAPI的原始JSON格式数据，导出该逻辑分组下所有接口的OpenAPI原始json格式。如下图：</p><p><img loading="lazy" src="/assets/images/downloadOpenAPI-6e62322739c45d49df3de173c4bb3ed9.png" width="989" height="255" class="img_ev3q"></p><p>10、针对单个接口，提供OpenAPI的源码格式，可以通过复制或者下载该源码格式直接导入POSTMAN进行测试<a href="https://gitee.com/xiaoym/knife4j/issues/I1Z7AP" target="_blank" rel="noopener">Gitee #I1Z7AP</a>。如下图：</p><p><img loading="lazy" src="/assets/images/singleOpenAPI-74295c1dc4186890fdd54e465359e3f3.png" width="1928" height="1062" class="img_ev3q"></p><p>11、增强注解<code>@EnableKnfie4j</code>增加Spring Boot中的Conditional条件<code>@ConditionalOnWebApplication</code>,仅在Web环境下加载，避免在使用<code>junit</code>单元测试时出现异常。</p><p>12、<strong>增强模式的改进,主要有两个变化,更加详细的使用规则</strong>，开发者请<a href="https://doc.xiaominfo.com/knife4j/enhance.html">参考文档</a>：</p><ul><li><p>提供<code>spring.factories</code>进行自动装置,开发者可以直接在Spring Boot的配置文件<code>yml</code>或者<code>property</code>等使用属性<code>knife4j.enable:true</code>进行开启使用，配置属性后无需再使用<code>@EnableKnife4j</code>注解</p></li><li><p>提供<code>spring-configuration.meta.json</code>文件，对<code>Knife4j</code>提供的各个增强配置属性进行注释，方便开发者在配置文件中进行配置，如下图：</p><p><img loading="lazy" src="/assets/images/yml-1-1a75ccd3abd623145f25640453fab513.png" width="518" height="296" class="img_ev3q"><img loading="lazy" src="/assets/images/yml-2-bb8bf71565fd8e7d5e9858a934b0637a.png" width="725" height="141" class="img_ev3q"></p></li></ul><p>13、针对其它文档的配置，开发者可以根据每一个逻辑分组Docket进行配置，其他文档支持自定义文档的分组标题</p><p>14、接口排序需求无需再Ui界面勾选增强，只需要在配置文件中开启<code>knife4j.enable=true</code>接口，然后使用<code>@ApiSupport</code>注解或者<code>@ApiSort</code>在<code>Controller</code>类上进行使用，优先级<code>@ApiSupport&gt;@ApiSort</code>,该方式更加融合了springfox框架的特性，也更符合对扩展属性扩展的规范，在OpenAPI结构节点增加<code>x-order</code>扩展参数，如下图：</p><p><img loading="lazy" src="/assets/images/x-order-f36f163c9d50a1d0b3b69eb0e1732c5c.png" width="717" height="186" class="img_ev3q"></p><p>15、移除增强扩展接口地址<code>/v2/api-docs-ext</code>,个性化配置及增强通过后端配置文件进行配置即可,通过更加规范的使用增强注解,符合OpenAPI的扩展属性规范。</p><p>16、其他文档以更加符合OpenAPI的扩展规范进行展示，开发者可以在yml配置文件中配置多个分组文档(<code>前提是knife4j.enable=true</code>),然后再创建的<code>Docket</code>对象中使用<code>Knife4j</code>提供的<code>OpenApiExtensionResolver</code>扩展<code>extension</code>,最终配置的md文件会在文档中进行分组呈现.<a href="https://github.com/xiaoymin/swagger-bootstrap-ui/issues/115" target="_blank" rel="noopener">GitHub #115</a></p><p><code>application.yml</code>配置示例代码如下：</p><div class="language-yml codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-yml codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token key atrule">knife4j</span><span class="token punctuation" style="color:rgb(248, 248, 242)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">  </span><span class="token key atrule">enable</span><span class="token punctuation" style="color:rgb(248, 248, 242)">:</span><span class="token plain"> </span><span class="token boolean important">true</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">  </span><span class="token key atrule">documents</span><span class="token punctuation" style="color:rgb(248, 248, 242)">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token punctuation" style="color:rgb(248, 248, 242)">-</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">      </span><span class="token key atrule">group</span><span class="token punctuation" style="color:rgb(248, 248, 242)">:</span><span class="token plain"> 2.X版本</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">      </span><span class="token key atrule">name</span><span class="token punctuation" style="color:rgb(248, 248, 242)">:</span><span class="token plain"> 接口签名</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">      </span><span class="token key atrule">locations</span><span class="token punctuation" style="color:rgb(248, 248, 242)">:</span><span class="token plain"> classpath</span><span class="token punctuation" style="color:rgb(248, 248, 242)">:</span><span class="token plain">sign/*</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token punctuation" style="color:rgb(248, 248, 242)">-</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">      </span><span class="token key atrule">group</span><span class="token punctuation" style="color:rgb(248, 248, 242)">:</span><span class="token plain"> 2.X版本</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">      </span><span class="token key atrule">name</span><span class="token punctuation" style="color:rgb(248, 248, 242)">:</span><span class="token plain"> 另外文档分组请看这里</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">      </span><span class="token key atrule">locations</span><span class="token punctuation" style="color:rgb(248, 248, 242)">:</span><span class="token plain"> classpath</span><span class="token punctuation" style="color:rgb(248, 248, 242)">:</span><span class="token plain">markdown/*</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="复制代码到剪贴板" title="复制" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>Java代码：</p><div class="language-java codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-java codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token plain">@Configuration</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">@EnableSwagger2WebMvc</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">@Import(BeanValidatorPluginsConfiguration.class)</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">public class SwaggerConfiguration {</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"> </span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">   private final OpenApiExtensionResolver openApiExtensionResolver;</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    @Autowired</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    public SwaggerConfiguration(OpenApiExtensionResolver openApiExtensionResolver) {</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">        this.openApiExtensionResolver = openApiExtensionResolver;</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    }</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    @Bean(value = &quot;defaultApi2&quot;)</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    public Docket defaultApi2() {</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">        String groupName=&quot;2.X版本&quot;;</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">        Docket docket=new Docket(DocumentationType.SWAGGER_2)</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                .host(&quot;https://www.baidu.com&quot;)</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                .apiInfo(apiInfo())</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                .groupName(groupName)</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                .select()</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                .apis(RequestHandlerSelectors.basePackage(&quot;com.swagger.bootstrap.ui.demo.new2&quot;))</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                //.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                .paths(PathSelectors.any())</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                .build()</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">            //此处调用openApiExtensionResolver的方法获取extensions集合</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                .extensions(openApiExtensionResolver.buildExtensions(groupName))</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">                .securityContexts(CollectionUtil.newArrayList(securityContext())).securitySchemes(CollectionUtil.newArrayList(apiKey()));</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">        return docket;</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    }</span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">}</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="复制代码到剪贴板" title="复制" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>最终Ui界面效果图：</p><p><img loading="lazy" src="/assets/images/document-daca6fe2429f6b42350206c16e17777a.png" width="581" height="454" class="img_ev3q"></p><p>17、针对使用<code>@ApiModelProperty</code>注解，给予实体String类型的属性字段赋值<code>example</code>示例值json字符串时显示异常的问题<a href="https://github.com/xiaoymin/swagger-bootstrap-ui/issues/233" target="_blank" rel="noopener">GitHub #233</a></p><p>18、请求示例和响应示例中的长整形精度丢失的问题<a href="https://github.com/xiaoymin/swagger-bootstrap-ui/issues/269" target="_blank" rel="noopener">GitHub #269</a></p><p>19、针对当前接口存在Authorze认证情况下，没有点击该功能时参数不会默认在接口调试中的Bug以及query类型参数始终出现在请求头参数栏的情况<a href="https://gitee.com/xiaoym/knife4j/issues/I1VC4I" target="_blank" rel="noopener">Gitee #I1VC4I</a></p><p>20、去除Ui界面中个性化设置中的启用增强配置。</p><p>21、增强注解<code>@ApiOperationSupport</code>与<code>@DynamicResponseParameters</code>同时使用时,动态响应字段丢失的问题<a href="https://gitee.com/xiaoym/knife4j/issues/I22K0R" target="_blank" rel="noopener">Gitee #I22K0R</a></p><p>22、离线文档下载失败的问题，变量引用错误导致<a href="https://gitee.com/xiaoym/knife4j/issues/I1W5UB" target="_blank" rel="noopener">Gitee #I1W5UB</a></p><h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="openapi3">OpenAPI3<a class="hash-link" href="#openapi3" title="标题的直接链接">​</a></h2><p>如果开发者想使用springfox的OpenAPI3的版本,Knife4j此次发布了两个版本,针对3.0版本,Knife4j底层升级springfox组件到<code>springfox3.0.0</code>,并且版本号从<code>3.x</code>系列开始,代表OpenAPI3,以区分<code>2.x</code>系列。</p><p>Maven引用</p><div class="language-xml codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#F8F8F2;--prism-background-color:#282A36"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-xml codeBlock_bY9V thin-scrollbar"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#F8F8F2"><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;</span><span class="token tag" style="color:rgb(255, 121, 198)">dependency</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;</span><span class="token tag" style="color:rgb(255, 121, 198)">groupId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain">com.github.xiaoymin</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;/</span><span class="token tag" style="color:rgb(255, 121, 198)">groupId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;</span><span class="token tag" style="color:rgb(255, 121, 198)">artifactId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain">knife4j-spring-boot-starter</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;/</span><span class="token tag" style="color:rgb(255, 121, 198)">artifactId</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token comment" style="color:rgb(98, 114, 164)">&lt;!--如果想使用springfox3.0及OpenAPI3请用3.x版本--&gt;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain">    </span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;</span><span class="token tag" style="color:rgb(255, 121, 198)">version</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain">3.0</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;/</span><span class="token tag" style="color:rgb(255, 121, 198)">version</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#F8F8F2"><span class="token plain"></span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&lt;/</span><span class="token tag" style="color:rgb(255, 121, 198)">dependency</span><span class="token tag punctuation" style="color:rgb(248, 248, 242)">&gt;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="复制代码到剪贴板" title="复制" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg class="copyButtonIcon_y97N" viewBox="0 0 24 24"><path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg class="copyButtonSuccessIcon_LjdS" viewBox="0 0 24 24"><path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>针对SpringFox3.0的版本,作者在开发过程中虽然在Ui上对OpenAPI3进行了支持,但是目前springfox3.0还存在诸多的问题，建议开发者慎重使用springfox3。不管是对于OpenApi2以及OpenApi3的支持，目前springfox3在兼容性等方面都存在一些问题,毕竟刚发布一个版本.</p><p>相对而言,springfox2.x系列的版本较稳定.当Springfox对于3.0的结构相对稳定后,Knife4j的主分支版本会向3.0靠拢。</p><p>相关ISSUES:</p><ul><li><a href="https://gitee.com/xiaoym/knife4j/issues/I1UGH7" target="_blank" rel="noopener">#I1UGH7 swagger 2.9.2 对 javax.validation 支持缺少，可考虑升级到 2.10.5</a></li><li><a href="https://gitee.com/xiaoym/knife4j/issues/I1R9J1" target="_blank" rel="noopener">#I1R9J1 关于支持 Springfox Swagger 3.0.0</a></li><li><a href="https://gitee.com/xiaoym/knife4j/issues/I1VYDM" target="_blank" rel="noopener">#I1VYDM 早日支持下springfox-boot-starter 3.0</a></li><li><a href="https://gitee.com/xiaoym/knife4j/issues/I1X27Y" target="_blank" rel="noopener">#I1X27Y swagger 升级到3.0后的兼容问题</a></li><li><a href="https://gitee.com/xiaoym/knife4j/issues/I1QQYH" target="_blank" rel="noopener">#I1QQYH knife4j-vue-v3 setInstanceBasicPorperties 方法中逻辑问题</a></li><li><a href="https://github.com/xiaoymin/swagger-bootstrap-ui/issues/275" target="_blank" rel="noopener">#275 springfox-3.0.0与knife4j-2.0.5冲突？</a></li><li><a href="https://github.com/xiaoymin/swagger-bootstrap-ui/issues/268" target="_blank" rel="noopener">#268 spring boot 2.3.3、springfox 3.0.0与knife4j2.0.4集成报错问题</a></li><li><a href="https://github.com/xiaoymin/swagger-bootstrap-ui/issues/265" target="_blank" rel="noopener">#265 spring-plugin-core的兼容问题</a></li></ul><h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="特点">特点<a class="hash-link" href="#特点" title="标题的直接链接">​</a></h2><ul><li>基于Vue+Ant Design构建的文档，更强大、清晰的接口文档说明能力以及接口调试能力</li><li>左右布局,基于Tabs组件的多文档查阅风格</li><li>支持在线导出Html、Markdown、Word、PDF等多种格式的离线文档</li><li>接口排序,支持分组及接口的排序功能</li><li>支持接口全局在线搜索功能</li><li>提供Swagger资源保护策略,保护文档安全</li><li>接口调试支持无限参数,开发者调试非常灵活，动态增加、删除参数</li><li>全局缓存调试信息,页面刷新后依然存在,方便开发者调试</li><li>以更人性化的table树组件展示Swagger Models功能</li><li>文档以多tab方式可显示多个接口文档</li><li>请求参数栏请求类型、是否必填着颜色区分</li><li>主页中粗略统计接口不同类型数量</li><li>支持自定义全局参数功能，主页包括header及query两种类型</li><li>JSR-303 annotations 注解的支持</li><li>更多个性化设置功能</li></ul><h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="界面">界面<a class="hash-link" href="#界面" title="标题的直接链接">​</a></h2><p>接口文档显示界面如下：</p><p><img loading="lazy" src="https://oscimg.oschina.net/oscnet/up-5b76509501c86174096f8b795d2aba8455b.png" class="img_ev3q"></p><p>接口调试界面如下：</p><p><img loading="lazy" src="https://oscimg.oschina.net/oscnet/up-995a784219ea035cacd428d15d04e9cbcb3.png" class="img_ev3q"></p><p>Swagger Models功能</p><p><img loading="lazy" src="https://oscimg.oschina.net/oscnet/up-98e1dbdf35ab957f5c05df126f9bae44ffd.png" class="img_ev3q"></p><p><img loading="lazy" src="https://oscimg.oschina.net/oscnet/up-d9a030b06b76f9a4935205df453af149788.png" class="img_ev3q"></p><p>支持导出离线Markdown、Html功能，markdown的表格较原先版本通过缩减显示为树形结构,<a href="https://doc.xiaominfo.com/html/knife4j-export-html.html">点击预览导出离线Html效果</a>，效果图如下：</p><p><img loading="lazy" src="https://oscimg.oschina.net/oscnet/up-cfb2256485835e29a39f96eaaa60251e08c.png" class="img_ev3q"></p><p>通过第三方Markdown软件导出的PDF效果如下图:</p><p><img loading="lazy" src="https://oscimg.oschina.net/oscnet/up-44bb80532b9767a33650e178809f612c3e7.png" class="img_ev3q"></p><p>同时提供了导出离线Html功能,Html功能界面风格和在线几乎没有区别,美观、大方、简洁,<a href="https://doc.xiaominfo.com/Knife4j-Offline-Html.html">点击在线预览效果</a>，</p><p>界面效果如下图：</p><p><img loading="lazy" src="https://oscimg.oschina.net/oscnet/up-4deb56c65774b4dc2ad54f5278f31e89a5d.png" class="img_ev3q"></p><h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="star--issue">Star &amp; Issue<a class="hash-link" href="#star--issue" title="标题的直接链接">​</a></h2><p>感谢各位朋友的支持,前往<a href="https://gitee.com/xiaoym/knife4j" target="_blank" rel="noopener">https://gitee.com/xiaoym/knife4j</a>点个Star吧~~ ：）</p></div><footer class="theme-doc-footer docusaurus-mt-lg"><div class="theme-doc-footer-edit-meta-row row"><div class="col"></div><div class="col lastUpdated_vwxv"><span class="theme-last-updated">最后<!-- -->由 <b>xiaoyumin</b> <!-- -->于 <b><time datetime="2022-08-14T10:05:39.000Z">2022年8月14日</time></b> <!-- -->更新</span></div></div></footer></article><nav class="pagination-nav docusaurus-mt-lg" aria-label="文档分页导航"><a class="pagination-nav__link pagination-nav__link--prev" href="/docs/changelog/x/2020-11-02-knife4j-2.0.7-issue"><div class="pagination-nav__sublabel">上一页</div><div class="pagination-nav__label">[v2.0.7-2020/11/02 Knife4j 2.0.7发布,细节处理]</div></a><a class="pagination-nav__link pagination-nav__link--next" href="/docs/changelog/x/2020-09-14-knife4j-2.0.5-issue"><div class="pagination-nav__sublabel">下一页</div><div class="pagination-nav__label">[v2.0.5-2020/09/14 Knife4j 2.0.5发布,性能优化]</div></a></nav></div></div><div class="col col--3"><div class="tableOfContents_bqdL thin-scrollbar theme-doc-toc-desktop"><ul class="table-of-contents table-of-contents__left-border"><li><a href="#特性--优化" class="table-of-contents__link toc-highlight">特性 &amp; 优化</a></li><li><a href="#openapi3" class="table-of-contents__link toc-highlight">OpenAPI3</a></li><li><a href="#特点" class="table-of-contents__link toc-highlight">特点</a></li><li><a href="#界面" class="table-of-contents__link toc-highlight">界面</a></li><li><a href="#star--issue" class="table-of-contents__link toc-highlight">Star &amp; Issue</a></li></ul></div></div></div></div></main></div></div><footer class="footer"><div class="container container-fluid"><div class="row footer__links"><div class="col footer__col"><div class="footer__title">文档指南</div><ul class="footer__items clean-list"><li class="footer__item"><a class="footer__link-item" href="/docs/quick-start">文档</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/community/simple-demo">示例</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/changelog">更新日志</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/upgrading/upgrading-to-v4">升级到v4.0</a></li></ul></div><div class="col footer__col"><div class="footer__title">社区</div><ul class="footer__items clean-list"><li class="footer__item"><a href="https://gitter.im/knife4j/knife4j" target="_blank" rel="noopener noreferrer" class="footer__link-item">Gitter<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li class="footer__item"><a href="https://www.oschina.net/question/tag/swagger-bootstrap-ui" target="_blank" rel="noopener noreferrer" class="footer__link-item">开源中国<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li></ul></div><div class="col footer__col"><div class="footer__title">关注公众号</div><ul class="footer__items clean-list"><li class="footer__item"><img src="/images/website/qrcode.jpg" width="150"></li></ul></div><div class="col footer__col"><div class="footer__title">更多</div><ul class="footer__items clean-list"><li class="footer__item"><a href="https://docusaurus.io" target="_blank" rel="noopener noreferrer" class="footer__link-item">Docusaurus<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li class="footer__item"><a href="https://gitee.com/xiaoym/knife4j" target="_blank" rel="noopener noreferrer" class="footer__link-item">Gitee<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li><li class="footer__item"><a href="https://github.com/xiaoymin/swagger-bootstrap-ui" target="_blank" rel="noopener noreferrer" class="footer__link-item">GitHub<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a></li></ul></div></div><div class="footer__bottom text--center"><div class="footer__copyright">Apache License 2.0 | Copyright © 2018-2023-八一菜刀 浙ICP备18027673号-1 </div></div></div></footer></div>
<script src="/assets/js/runtime~main.e0db172c.js"></script>
<script src="/assets/js/main.c059fb6e.js"></script>
<!-- Google Tag Manager (noscript) -->
    <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-TKBX678" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
    <!-- End Google Tag Manager (noscript) --></body>
</html>